<?php

namespace app\admin\model;

use think\Model;

/**
 * 会员用户模型
 * @package app\admin\model
 */
class UsersMember extends Model
{
    # 设置当前模型对应的完整数据表名称
    protected $name = 'admin_users_member';

    # 自动写入时间戳
    protected $autoWriteTimestamp = true;

    /**
     * 设置会员到期时间
     * @param $memberLevel
     * @param $times
     * @return float|int
     */
    public static function setMemberExpireTime($memberLevel, $times)
    {
        // 小于当前时间：新会员
        $currentTime = $times < time() ? time() : $times;
        $endTime = $currentTime + $memberLevel['validity'] * 24 * 3600;
        return $endTime;
    }

}